//
//  ViewController.m
//  链式编程01
//
//  Created by 许卫星 on 16/12/26.
//  Copyright © 2016年 许卫星. All rights reserved.
//

#import "ViewController.h"
#import "Caculator.h"
#import "NSObject+CaculatorMaker.h"
#import "CaculatorFunction.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self caculatorFunction];
}

- (void)caculator
{
    NSInteger result = [NSObject makerCaculators:^(Caculator *caculator) {
        caculator.add(10).reduction(5).multiplication(3).division(5);
        BOOL isEqule = caculator.multiplication(10).equle(300).isEqule;
        NSLog(@"---------%ld",(long)isEqule);
    }];
    NSLog(@"---------%ld",(long)result);
}

- (void)caculatorFunction
{
    CaculatorFunction *caculatorFunction = [[CaculatorFunction alloc] init];
    BOOL isEqule = [[caculatorFunction caculatorFunction:^int(int result) {
        result += 10;
        result += 10;
        result += 10;
        NSLog(@"---------%ld",(long)result);
        return result;
    }] equle:^BOOL(int result) {
        return result == 30;
    }];
     NSLog(@"---------%ld",(long)isEqule);
}
@end
